﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//
using iPublic;

namespace HRecycle.Comm
{
    /// <summary>
    /// 识别成功后，客户的选择
    /// 修改记录：
    ///   20171214，zch，创建基本功能
    /// </summary>
    public partial class FrmShiBieOK : Form
    {
        public iDefine.jsonShibieOK shibie = null;          //识别出来的东西

        public FrmShiBieOK()
        {
            InitializeComponent();
        }

        private void FrmShiBieOK_Load(object sender, EventArgs e)
        {
            try
            {
                showInfo("★★进入识别成功选择单元★★");
                FormBorderStyle = FormBorderStyle.None;
            }
            catch (Exception x)
            { showInfo(x.Message); }
        }

        private void FrmShiBieOK_Shown(object sender, EventArgs e)
        {
            if (shibie == null) return;
            iDefine.jsonShibieItem item = shibie.result[0];
            lbl_Items.Text = item.id + "," + item.description + "(" + item.description_en + ")";
            //启动计时器
            //tm_main.Interval = Convert.ToInt16(lbl_time.Text) * 1000;   //秒数
            tm_main.Enabled = true;
        }
        private void tm_main_Tick(object sender, EventArgs e)
        {
            Timer tm = sender as Timer;
            bool lEnable = tm.Enabled;
            tm.Enabled = false;
            //
            int n = Convert.ToInt16(lbl_time.Text) - 1;
            lbl_time.Text = n.ToString();
            //
            if (n <= 0) btn_ok_Click(sender, e); else tm.Enabled = lEnable;
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {   //确定、结束
            DialogResult = DialogResult.OK;
            Close();
        }

        private void btn_continue_Click(object sender, EventArgs e)
        {   //继续投放
            DialogResult = DialogResult.Ignore;
            Close();
        }

        private void btn_retry_Click(object sender, EventArgs e)
        {   //重试
            DialogResult = DialogResult.Retry;
            Close();
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {   //取消，不投了
            DialogResult = DialogResult.Cancel;
            Close();
        }

        public void showInfo(string sInfo, bool lTime = true)
        {
            lbl_info.Text = sInfo;
            iLog.writeLogFile(sInfo);
        }

    }
}
